//
//  LYmineViewController.m
//  音伴尔家听宝
//
//  Created by Burgess on 2017/4/10.
//  Copyright © 2017年 Burgess. All rights reserved.
//

#import "LYmineViewController.h"
#import "LYmineView.h"

@interface LYmineViewController () <LYmineViewdelegate>

@end

@implementation LYmineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.tintColor = [UIColor redColor];
    self.tableView = [[UITableView alloc]initWithFrame:self.tableView.bounds style:UITableViewStyleGrouped];
    
}

-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden    =   YES;
}

-(void)viewWillDisappear:(BOOL)animated{
    self.navigationController.navigationBar.hidden     =  NO;
}

#pragma mark - UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 4;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        LYmineView * mineView     = [LYmineView initmineview];
        
        NSString *path = [YbrSandBox dicAppendFilePath:initfilename];
        NSDictionary *dicc = [NSDictionary dictionaryWithContentsOfFile:path];
        NSString *str =  dicc[@"userid"];
        
        mineView.bounds               = CGRectMake(0, 0, 375, 380);
        mineView.delegate             =  self;
        [mineView.loginBtn setTitle:str forState:UIControlStateNormal];
        
        return mineView;
    }
    return NULL;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return 380;
    }
    return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell * cell;

    NSArray  *array  = @[@"bag",@"heart",@"time",@"local"];
    NSArray * lebel = @[@"我的书包",@"我喜欢的",@"播放历史",@"所在城市"];
        cell = [tableView dequeueReusableCellWithIdentifier:@"id"];
        if (cell == NULL) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"id"];
                    }
    [tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    if (indexPath.row !=3) {
        UIView * view=  [[UIView alloc]initWithFrame:CGRectMake(0, 54, 375, 1)];
        view.alpha = 0.1;
        view.backgroundColor = [UIColor grayColor];
        [cell addSubview:view];
    }
        cell.imageView.image = [UIImage imageNamed:array[indexPath.row]];
        cell.textLabel.text = lebel[indexPath.row];

    cell.accessoryType =  UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (section == 2) {
        return 100;
    }else
        return 0;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 55;
}

#pragma mark - UITableViewDelegate

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"%ld",indexPath.row);
}

#pragma mark - 用户头视图的delegate

//  点击用户头像
-(void)userIconClick{
    NSLog(@"%s",__func__);
}

 // 点击登录按钮
-(void)loginBtnClick{
    NSLog(@"%s",__func__);
}

//  我的声音、我的课程、我的关注、我的粉丝四个按钮的点击事件
-(void)fourMyBtnClick:(id)sender{
    NSLog(@"%s",__func__);
    NSLog(@"%@",sender);
}

//  点击录音按钮
-(void)recordBtnClick{
    NSLog(@"%s",__func__);
}

@end
